package com.dianping.cat.consumer.state.model.transform;
import com.dianping.cat.consumer.state.model.entity.Detail;
import com.dianping.cat.consumer.state.model.entity.Machine;
import com.dianping.cat.consumer.state.model.entity.Message;
import com.dianping.cat.consumer.state.model.entity.ProcessDomain;
import com.dianping.cat.consumer.state.model.entity.StateReport;
import java.util.ArrayList;
import java.util.List;

public class DefaultLinker implements ILinker {
  private boolean m_deferrable;
  
  public DefaultLinker(boolean deferrable) {
/* 14 */     this.m_deferedJobs = new ArrayList();


/* 17 */     this.m_deferrable = deferrable;
  }
  private List<Runnable> m_deferedJobs;
  public void finish() {
/* 21 */     for (Runnable job : this.m_deferedJobs) {
/* 22 */       job.run();
    }
  }

  
  public boolean onDetail(final ProcessDomain parent, final Detail detail) {
/* 28 */     if (this.m_deferrable) {
/* 29 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 32 */               parent.addDetail(detail);
            }
          });
    } else {
/* 36 */       parent.addDetail(detail);
    }
    
/* 39 */     return true;
  }

  
  public boolean onMachine(final StateReport parent, final Machine machine) {
/* 44 */     if (this.m_deferrable) {
/* 45 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 48 */               parent.addMachine(machine);
            }
          });
    } else {
/* 52 */       parent.addMachine(machine);
    }
    
/* 55 */     return true;
  }

  
  public boolean onMessage(final Machine parent, final Message message) {
/* 60 */     if (this.m_deferrable) {
/* 61 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 64 */               parent.addMessage(message);
            }
          });
    } else {
/* 68 */       parent.addMessage(message);
    }
    
/* 71 */     return true;
  }

  
  public boolean onProcessDomain(final Machine parent, final ProcessDomain processDomain) {
/* 76 */     if (this.m_deferrable) {
/* 77 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 80 */               parent.addProcessDomain(processDomain);
            }
          });
    } else {
/* 84 */       parent.addProcessDomain(processDomain);
    }
    
/* 87 */     return true;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/lib/cat-consumer-3.0.0.jar!/com/dianping/cat/consumer/state/model/transform/DefaultLinker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */